import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // 启动要显示的界面
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("图标组件示例"),
      ),
      body: MyHomeBody(),
    );
  }
}

class MyHomeBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    /**
     * Stack 默认的大小是包裹内容的
     *  - alignment：从什么位置开始排布所有的子 Widget
     *  - fit：StackFit.expand 很少用，将子元素拉伸到尽可能大
     *  - overflow: 超出部分如何处理
     */
    return Stack(
      alignment: Alignment.topRight,
//      fit: StackFit.expand,
      overflow: Overflow.clip,
      children: <Widget>[
        Image.asset("assets/images/iron.png"),
        Positioned(
          top: 20,
          left: 20,
          height: 20,
          width: 20,
          child: Container(
            width: 100,
            height: 100,
            color: Colors.red,
          ),
        ),
        Positioned(
            top: 60,
            left: 20,
            width: 150,
            height: 100,
            child: Text(
              "Hello World",
              style:
              TextStyle(color: Colors.brown, backgroundColor: Colors.green),
            ))
      ],
    );
  }
}
